//
//  ItemListController.h
//  NewsReader
//
//  Created by blacksun on 10-10-17.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "Feed.h"
#import "Section.h"
#import "TableCellController.h"
#import "URLAddress.h"
#import "HttpUtil.h"
#import "NewsReaderAppDelegate.h"
#import "EGORefreshTableHeaderView.h"
#import "ImageDownloader.h"
#import "User.h"
#import "FeedService.h"


@class CustomDetailViewController;

#define kBackgroundImage 100
#define kFeedTitle		201
#define kFeedImage1		202
#define kFeedImage2		203
#define kFeedImage3		204
#define kFeedDescribtion 205
#define kFeedDate		206
#define kFeedAuthor		207
#define kFeedView		1000
#define kStartView		300
#define kTableCellHeight	110.0
#define kNotificationCenterName @"updateSucess"

#define kDefaultSectionIndex    999

@interface ItemListController : UIViewController <ImageDownloaderDelegate,UITableViewDelegate,UITableViewDataSource,ServiceDelegate>{
	NSMutableArray *newItems;   
	Section *section;
	EGORefreshTableHeaderView *headerView;
	EGORefreshTableHeaderView *footerView;
	BOOL _reloading;
	NSMutableDictionary *imageDownloadsInProgress;
	NSMutableArray *httpUtils;
	UITableView *tableView;
	UILabel *titleLabel;
	UIView *loadingView;
	NSOperationQueue* operationQueue; 
	User *user;
	NSNotificationCenter *notificationCenter;
	FeedService *feedService;
    
    NSInteger currentSectionIndex;
    NSInteger maxIndex;
    NSInteger minIndex;
    UIImageView *listTopImageView;
    UIScrollView *titleScroll;
    UIImageView *currentImage;

}
@property (nonatomic, retain) IBOutlet UIImageView *currentImage;
@property (nonatomic, retain) IBOutlet UIScrollView *titleScroll;
@property (nonatomic, retain) IBOutlet UIImageView *listTopImageView;
@property (nonatomic, retain) FeedService *feedService;
@property (nonatomic, retain) NSNotificationCenter *notificationCenter;
@property (nonatomic, retain) User *user;
@property (nonatomic, retain) NSOperationQueue* operationQueue; 
@property (nonatomic, retain) IBOutlet UIView *loadingView;
@property (nonatomic, retain) EGORefreshTableHeaderView *footerView;
@property (nonatomic, retain) NSMutableArray *newItems; 
@property (nonatomic, retain) Section *section;
@property(assign,getter=isReloading) BOOL reloading;
@property (nonatomic, retain) NSMutableDictionary *imageDownloadsInProgress;
@property (nonatomic, retain) NSMutableArray *httpUtils;	
@property (nonatomic, retain) IBOutlet UITableView *tableView;
@property (nonatomic, retain) IBOutlet UILabel *titleLabel;

-(IBAction) goBack:(id)sender;
-(void) finishHttpRequest:(NSMutableData *)responseData;
-(void) itemsReloaded:(NSArray *)items;
-(void) loadNewFeeds;
-(void) loadLastFeeds;
-(void) loadOlderFeeds;
-(void) startIconDownload:(Feed *)feed forIndexPath:(NSIndexPath *)indexPath;
-(void) addNotificationAbserver:(id)observer selector:(SEL)aSelector;
-(void) removeNotificationAbserver:(id)observer;
-(void) updateFeedsContents:(NSArray *)feeds;
-(IBAction) changeSection:(id)sender;

-(Section *)getSelectedSection;


@end
